#pragma once

#ifndef C_NETWORKHANDLER_H
#define C_NETWORKHANDLER_H

#include <qobject.h>
#include <QTcpSocket>
#include <QTimer>
#include <QThread>
class Networkhandler :
    public QObject 
{
    Q_OBJECT
public:
    explicit Networkhandler(QObject* parent = nullptr);
    ~Networkhandler();
public slots:
    void connectToHost(const QString &host,quint16 port);
    void sendData(const QByteArray& data);
    void disconnectHost();

signals:
    void toConnected();
    void toDisconnected();
    void dataReceived(const QByteArray &data);
    void toErrorOccurred(const QString& error);

private slots:
    void onReadyRead();
    void onError(QAbstractSocket::SocketError error);

private:

    QTcpSocket* socket;
    QTimer timeOut;


};

#endif